/****** Object:  StoredProcedure [dbo].[sp_ConsolManifest]    Script Date: 10/10/2013 15:13:23 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_ConsolManifest]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_ConsolManifest]
GO
/****** Object:  StoredProcedure [dbo].[sp_ConsolManifest]    Script Date: 10/10/2013 15:13:23 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Tuan Chau>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_ConsolManifest]
	-- Add the parameters for the stored procedure here
	@JobNo nvarchar(100),
	@Pieces nvarchar(100),
	@Weight numeric(16,9)
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	Select
	T0.U_CarrierN,
	T4.U_ShipperNameAddress,
	T0.U_LoadPortCC,
	U_DisPortCC,
	T4.U_ConsigneeNameAddr,
	T4.U_AWBNo,
	T1.U_HAWBNo,
	U_Pieces = Convert(int,T3.U_Pieces),	
	T2.U_Destination,
	T1.U_WTPPC,
	T1.U_OtherCOLL,
	T1.U_ShipperNameAddress,
	T1.U_ConsigneeNameAddr,
	U_NatQty
From
	[@AB_AIRE_JOB_H] T0
	Left Join [@AB_AWB_H] T1 on T0.U_JobNo = T1.U_JobNo
	Left Join [@AB_AWB_H1] T2 on T1.DocEntry = T2.DocEntry
	Left Join [@AB_AWB_H2] T3 on T1.DocEntry = T3.DocEntry
	Left Join [@AB_AWB_M] T4 on T0.U_JobNo = T4.U_JobNo
Where
	T0.U_JobNo = @JobNo
END

GO


